// components/address/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    addressName:{
      type: String,
      value:""
    },
    addressId:{
      type: Number,
      value:0
    },
    addressList:{
      type: Array,
      value:[]
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    show:false,
    customItem: '全部',
    region: null,
    selectRegion:'全部'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    clickSelect:function(){
      this.setData({
        show: !this.data.show
      })
    },
    RegionChange: function(e) {
      let value = e.detail.value
      this.setData({
        region: value
      })

      this.regionSelectHandler(value);

      this.triggerEvent('onRegion',{
        addressName:this.data.selectRegion
      },{})
    },
    regionSelectHandler:function (region) {
      let value = ''
      if (region == null) {
        value = '全部';
      }
      if (region[1] == '全部') {
        value = region[0];
      }else {
        value = region[1];
      }
      this.setData({
        selectRegion: value
      })
    }
  }
})
